#include <stdio.h>
#include <stdlib.h>

#define NULL ((void *)0)

typedef struct ll_s
{
	int value;
	struct ll_s *next;
} ll_t;

int main(int argc, char *argv[])
{
	int size, k;
	ll_t *append, *curr;

	if (argc != 2)
	{
		printf("Usage: ll <size>\n");
		printf("\n");
		printf("    where:\n");
		printf("        <size> = # items in the list\n");
		return -1;
	}

#if 0
	for (k=0; k<argc; k++)
	{
		printf("arg %d: %s\n", k, argv[k]);
	}
#endif

	size = atoi(argv[1]);
	ll_t *head = NULL;
	ll_t *tail = head;
	for (k=0; k<size; k++)
	{
		ll_t *append = malloc(sizeof(ll_t));
		append->value = k;
		append->next = NULL;
		if (!tail)
		{
			tail = append;
		}
		else
		{
			tail->next = append;
			tail = append;
		}

		if (!head)
		{
			head = tail;
		}
	}
	
	curr = head;
	while (curr)
	{
		printf("Curr: %d\n", curr->value);
		curr = curr->next;
	}
	return 0;
}
